package com.ufaud.ais.pub.service;

import java.io.Serializable;
import java.util.List;

/**
 * Generic Manager that talks to GenericReopsitory to CRUD POJOs.
 *
 * <p>Extend this interface if you want typesafe (no casting necessary) managers
 * for your domain objects.
 *
 * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a>
 * @param <T> a type variable
 * @param <PK> the primary key for that type
 * @modifier 林可
 * <p>简单地继承了查询服务接口：
 * 		<ol>
 *			<li>以本接口的实体泛型&lt;T&gt;作为查询接口的返回结果泛型</li>
 * 			<li>具体化查询接口的查询参数泛型&lt;P&gt;为Map&lt;String, Object&gt;</li>
 * 		</ol>
 * </p>
 */
public interface IGenericCRUDService<T, PK extends Serializable> {

    /**
     * Generic method used to get all objects of a particular type. This
     * is the same as lookup up all rows in a table.
     * @return List of populated objects
     */
    List<T> getAll();

    /**
     * Generic method to get an object based on class and identifier. An
     * ObjectRetrievalFailureException Runtime Exception is thrown if
     * nothing is found.
     *
     * @param id the identifier (primary key) of the object to get
     * @return a populated object
     * @see org.springframework.orm.ObjectRetrievalFailureException
     */
    T get(PK id);

    /**
     * Checks for existence of an object of type T using the id arg.
     * @param id the identifier (primary key) of the object to get
     * @return - true if it exists, false if it doesn't
     */
    boolean exists(PK id);

    /**
     * Generic method to save an object - handles both update and insert.
     * @param object the object to save
     * @return the updated object
     */
    PK save(T object);

    /**
     * Generic method to delete an object based on class and id
     * @param id the identifier (primary key) of the object to remove
     */
    void remove(PK id);
	
}
